import java.util.*;
public class BestSeqAtIndex {
  public int bestSeqAtIndex(int[] height, int[] weight) {
      int[][] arr = new int[height.length][2];
      for(int i=0;i<height.length;i++){
        arr[i][0] = height[i];
        arr[i][1] = weight[i];
      }
      Arrays.sort(arr, new Comparator<int[]>(){
        public int compare(int[] a, int[] b){
          if(a[0] == b[0])
            return b[1] - a[1];
          return b[0] - a[0];
        }
      });
      int max = 0;
      int[] dp = new int[arr.length];
      Arrays.fill(dp, 1);
      for(int i=0;i<arr.length;i++){
        for(int j = 0; j < i; j++) {
          if(arr[i][1] < arr[j][1] && arr[i][0] < arr[j][0]){
            dp[i] = Math.max(dp[i], dp[j] + 1);
            max = Math.max(max, dp[i]);
          }
        } 
      }
      return max;
  }

  public static void main(String[] args) {
    int[] height = {65,70,56,75,60,68};
    int[] weight = {100,150,90,190,95,110};
    BestSeqAtIndex bestSeqAtIndex = new BestSeqAtIndex();
    int res = bestSeqAtIndex.bestSeqAtIndex(height, weight);
    System.out.println(res);
  }
}
